//
//  WTVideoView.m
//  WTLiveSDKDemo
//
//  Created by ben on 16/10/11.
//  Copyright © 2016年 ben. All rights reserved.
//

#import "WTVideoView.h"
#import "Masonry.h"
#import "WTLiveSDK.h"
#import "WTGiftAnimationManager.h"
#import "WTSendGiftManager.h"
#import "WTBarrageManager.h"
#import "KLCPopup.h"
#import "WTPersonInfoView.h"
#import "WTCategories.h"

@interface WTVideoView ()
@property (nonatomic,assign) NSInteger currentIndex;
@property (nonatomic, strong)  KLCPopup*             personPopup;
@property (nonatomic, strong)  WTPersonInfoView*     popPersonInfoView;
@end

@implementation WTVideoView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}


#pragma mark setup
- (void)setup{
    
    self.liveExtendView = ({
        WTLiveExtendView* view = [[WTLiveExtendView alloc] init];
        [self addSubview:view];
        view;
    });
    
    self.playToolView = ({ 
        WTPlayToolView* view = [[WTPlayToolView alloc] init];
        [self addSubview:view];
        view;
    });
    
    self.giftListView = ({
        WTGiftListView* view = [[WTGiftListView alloc] init];
        [self addSubview:view];
        view;
    });
    
    self.privateMessageView = ({
        WTPrivateMessageView* view = [[WTPrivateMessageView alloc] init];
        [self addSubview:view];
        view;
    });
    
    [self layout];
}


#pragma mark  layout
- (void)layout{
    
    [self.liveExtendView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.and.trailing.and.top.mas_equalTo(0);
        make.bottom.mas_equalTo(-52);
    }];
    
    [self.playToolView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.and.trailing.and.bottom.mas_equalTo(0);
        make.height.mas_equalTo(52);
    }];
    
    [self.giftListView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.and.trailing.mas_equalTo(0);
        make.height.mas_equalTo(252);
        make.bottom.mas_equalTo(252);
    }];
    
    [self.privateMessageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.and.trailing.mas_equalTo(0);
        make.bottom.mas_equalTo(252);
        make.height.mas_equalTo(252);
    }];
    
    [self handle];
}


#pragma mark add events
- (void)handle{
    
    __weak __typeof(self)weakSelf = self;
    self.playToolView.itemPressedBlock = ^(NSInteger index){
      
        switch (index) {
            case 0:{
                weakSelf.currentIndex = 0;
                [weakSelf.liveExtendView.chatInputView popKeyBoard];
            }
                break;
            case 1:{
                weakSelf.currentIndex = 1;
                [weakSelf.privateMessageView mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.bottom.mas_equalTo(0);
                }];
                [UIView animateWithDuration:.25 animations:^{
                    weakSelf.liveExtendView.chatBlankButton.alpha = 1;
                    [weakSelf layoutIfNeeded];
                }];
            }
                break;
            case 2:{ //礼物
                
                weakSelf.currentIndex = 2;
                [weakSelf.giftListView mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.bottom.mas_equalTo(0);
                }];
                CGFloat offset = 252 - 120;
                [weakSelf.liveExtendView mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_equalTo(-offset);
                    make.bottom.mas_equalTo(-offset);
                }];
                
                [UIView animateWithDuration:.25 animations:^{
                    weakSelf.playToolView.alpha = 0;
                    weakSelf.liveExtendView.chatRoomView.alpha = 0;
                    weakSelf.liveExtendView.chatBlankButton.alpha = 1;
                    [weakSelf layoutIfNeeded];
                }];
            }
                break;
            case 3:{
               
            }
                break;
            case 4:{
                
                if(weakSelf.playToolView.isLivePage){
                    //切换摄像头
                    if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoViewChangeCamera:)]){
                        [weakSelf.delegate videoViewChangeCamera:weakSelf];
                    }
                }else {
                    [UIView animateWithDuration:.25 animations:^{
                        [weakSelf.liveExtendView showOrHide];
                        [weakSelf.playToolView showOrHide];
                    }];
                }
            }
                break;
                
            default:{
               
            }
                break;
        }
    };
    
    self.liveExtendView.sendToDeductionBlock = ^(NSString* content,BOOL isDanmu){

        if(!content || content.length <= 0){
            [weakSelf showTip:@"消息不能为空"];
            return;
        }
        
        long long leftCoinValue = 0;
        if(isDanmu){
            //判断余额是否足够
             leftCoinValue = [weakSelf.giftListView.leftCoinValue longLongValue] -  1;
            if(leftCoinValue < 0){
                [weakSelf showTip:@"萝卜余额不足，请充值"];
                return;
            }
        }
        
        //发送消息
        NIMMessage* message = nil;
        if(isDanmu){
            message = [[WTLiveSDK shareSDK].chatRoomManager sendChatRoomDamuMessage:content];
        }else {
            message = [[WTLiveSDK shareSDK].chatRoomManager sendChatRoomMessage:content];
        }
        if(!message){
            [weakSelf showTip:@"消息发送失败,请重试."];
            return;
        }
        
        WTBaseMessageModel* chatroomMessageModel = [WTMessageFactory chatRoomMessageModelWithRemoteExt:message.remoteExt];
        chatroomMessageModel.chat_room_message_text = message.text;
        chatroomMessageModel.chat_room_message_message_id = message.messageId;
        
        if(isDanmu){
            
            [weakSelf.liveExtendView.barrageView insertTextOfData:@{@"name":chatroomMessageModel.chat_room_message_avtar_name,@"text":chatroomMessageModel.chat_room_message_text}];
            
            //更新本地的萝卜余额
            NSString* leftCoinString = [NSString stringWithFormat:@"%lld", leftCoinValue];
            weakSelf.giftListView.leftpriceValueLabel.text = [NSString stringWithFormat:@"%@%@",@"萝卜余额:",leftCoinString];
            
            WTBarrageSendModel* model  = [[WTBarrageSendModel alloc] init];
            model.barrage_send_to_user_id = weakSelf.privateMessageView.anchor_info_model.anchor_user_id;
            model.barrage_content = content;
            [[WTBarrageManager sharedManager] addBarrage:model send_to_user_id:weakSelf.privateMessageView.anchor_info_model.anchor_user_id];
        }else {
            [weakSelf.liveExtendView.chatRoomView insert:@[chatroomMessageModel]];
        }
    };
    
    
    [[WTGiftAnimationManager sharedManager] setGiftContainerView:self.liveExtendView.giftContainer];
    
    //chat message
    [[WTLiveSDK shareSDK].chatManager addChatMessagesReceivedCallBackBlock:^(NSArray<WTBaseMessageModel *> *messageModels) {
       
        
        if(messageModels.count <= 0){
            return;
        }
        NSArray* chatroomMessageModels = [messageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"sessionType == %d",NIMSessionTypeChatroom]];
        NSArray* chatMessageModels = [messageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"sessionType == %d",NIMSessionTypeP2P]];
        
        NSArray* roomMessages = [chatroomMessageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"chat_room_message_messagetype == %d",WTChatRoomMessageText]];
        NSArray* roomEnterMessages = [chatroomMessageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"chat_room_message_messagetype == %d",WTChatRoomMessageEnter]];
        NSArray* roomGiftMessages = [chatroomMessageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"chat_room_message_messagetype == %d",WTChatRoomMessageSendGift]];
        NSArray* roomBarrageMessages = [chatroomMessageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"chat_room_message_messagetype == %d",WTChatRoomMessageDanmuText]];
        NSArray* roomOwnerLeaveMessages = [chatroomMessageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"chat_room_message_messagetype == %d",WTChatRoomMessageOwnerLeave]];
        NSArray* roomOwnerEnterMessages = [chatroomMessageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"chat_room_message_messagetype == %d",WTChatRoomMessageOwnerEnter]];
        
        NSArray* roomOwnerFinishLiveMessages = [chatroomMessageModels filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"chat_room_message_messagetype == %d",WTChatRoomMessageExitLive]];
        
        //处理主播离开消息
        if(roomOwnerLeaveMessages.count > 0){
            if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoViewOwnerLeave:)]){
                [weakSelf.delegate videoViewOwnerLeave:weakSelf];
            }
        }
        
        //处理主播回来消息
        if(roomOwnerEnterMessages.count > 0){
            if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoViewOwnerEnter:)]){
                [weakSelf.delegate videoViewOwnerEnter:weakSelf];
            }
        }
        
        //主播结束直播
        if(roomOwnerFinishLiveMessages.count > 0){
            if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoViewOwnerFinishedLive:)]){
                [weakSelf.delegate videoViewOwnerFinishedLive:weakSelf];
            }
        }

        //处理聊天室的消息
        if(roomMessages.count > 0){
            [weakSelf.liveExtendView.chatRoomView insert:roomMessages];
        }
        
        //处理进入房间的消息
        if(roomEnterMessages.count > 0){
            
            [weakSelf.liveExtendView.chatRoomView insert:roomEnterMessages];
            //刷新观众列表
            [weakSelf.liveExtendView.visitorsView fetch];
            //刷新房间人数
            [[WTLiveSDK shareSDK].chatRoomManager fetchChatRoomPersonCount:[NSString stringWithFormat:@"%zd",weakSelf.roomId] completion:^(NSInteger onlinePersonCount) {
                weakSelf.liveExtendView.personInfoView.personCount = [NSString stringWithFormat:@"%zd人",onlinePersonCount];
            }];   
        }
        
        
        
        //处理礼物消息
        if(roomGiftMessages.count > 0){
            
            NSInteger needAddNum = 0;
            
            for(WTBaseMessageModel* chatroomMessageModel in roomGiftMessages){
                
                [[WTGiftAnimationManager sharedManager] animate:chatroomMessageModel.chat_room_message_user_id giftID:chatroomMessageModel.chat_room_message_gift_model.gift_id giftModel:chatroomMessageModel.chat_room_message_gift_model finishedBlock:nil];
                needAddNum += [weakSelf countGiftNum:chatroomMessageModel.chat_room_message_gift_model];
            }
            //更新主播端左上角的金币
            long long value = [weakSelf.liveExtendView.coinView.coinCount longLongValue] + needAddNum;
            weakSelf.liveExtendView.coinView.coinCount = [NSString stringWithFormat:@"%lld",value];
        }
        
        //处理私信会话消息
        if(chatMessageModels.count > 0){
            [weakSelf.privateMessageView.chatLetterView insertMessages:chatMessageModels];
        }
        
        //处理弹幕消息
        for(WTBaseMessageModel* barrageMessageModel in roomBarrageMessages){
            [weakSelf.liveExtendView.barrageView insertTextOfData:@{@"name":barrageMessageModel.chat_room_message_avtar_name,@"text":barrageMessageModel.chat_room_message_text}];
        }
    }];
    
    //gift list
    [self.giftListView.rechargeButton addAction:^ {
        
    }];
    
    [self.giftListView.sendButton addAction:^ {
        
        WTChatRoomGiftModel* model = [weakSelf.giftListView giftModel];
        if(!model){
            [weakSelf showTip:@"请先选择一个礼物"];
            return;
        }
        
        //判断余额是否足够
        long long leftCoinValue = [weakSelf.giftListView.leftCoinValue longLongValue] -  model.gift_count * model.gift_price;
        NSLog(@"%lld------%zd-----%lld",[weakSelf.giftListView.leftCoinValue longLongValue],model.gift_count * model.gift_price,leftCoinValue);
        if(leftCoinValue < 0){
            [weakSelf showTip:@"萝卜余额不足，请充值"];
            return;
        }
        NSDictionary* giftInfo = @{@"type":@(WTChatRoomMessageSendGift),
                                   @"name":WTConfig.nick,
                                   @"icon":WTConfig.avatar,
                                   @"gift_count":@(model.gift_count),
                                   @"gift_name":model.gift_name,
                                   @"gift_type":model.gift_id,
                                   @"gift_icon":model.gift_image_url,
                                   @"gift_price":@(model.gift_price),
                                   @"gift_scale":@(model.gift_scale),
                                   @"user_id":WTConfig.user_id,
                                   @"net_ease_id":WTConfig.net_accid};
        NIMMessage* message =  [[WTLiveSDK shareSDK].chatRoomManager sendGift:giftInfo];
        if(!message){
            [weakSelf showTip:@"礼物赠送失败,请重试."];
            return;
        }
        
        
        //更新本地的萝卜余额
        NSString* leftCoinString = [NSString stringWithFormat:@"%lld", leftCoinValue];
        weakSelf.giftListView.leftCoinValue = @(leftCoinValue);
        weakSelf.giftListView.leftpriceValueLabel.text = [NSString stringWithFormat:@"%@%@",@"萝卜余额:",leftCoinString];
        
        
        WTBaseMessageModel* chatroomMessageModel = [WTMessageFactory chatRoomMessageModelWithRemoteExt:giftInfo];
        chatroomMessageModel.chat_room_message_gift_model.send_gift_to_user_id = weakSelf.privateMessageView.anchor_info_model.anchor_user_id;
        
        //加入显示礼物的动画队列
        [[WTGiftAnimationManager sharedManager] animate:chatroomMessageModel.chat_room_message_user_id giftID:[NSString stringWithFormat:@"%zd",chatroomMessageModel.chat_room_message_gift_model.gift_id] giftModel:chatroomMessageModel.chat_room_message_gift_model finishedBlock:nil];
        
        //加入扣除礼物费用的队列
        [[WTSendGiftManager sharedManager] addGiftModel:chatroomMessageModel.chat_room_message_gift_model];
        
        //更新左上角的金币
        long long value = [weakSelf.liveExtendView.coinView.coinCount longLongValue] + [weakSelf countGiftNum:model];
        weakSelf.liveExtendView.coinView.coinCount = [NSString stringWithFormat:@"%lld",value];
        
        
    }];
    

    [self.liveExtendView.chatBlankButton addAction:^ {
        
        if(weakSelf.currentIndex == 0){
            
            [weakSelf.liveExtendView.chatInputView dismissKeyBoard];
            
        }else if(weakSelf.currentIndex == 1){

            if([weakSelf.privateMessageView isChatStatus]){
                
                [weakSelf.privateMessageView dismissKeyBoard];
            }else {
                
                [weakSelf.privateMessageView mas_updateConstraints:^(MASConstraintMaker *make) {
                    make.bottom.mas_equalTo(252);
                }];
                [UIView animateWithDuration:.25 animations:^{
                    weakSelf.liveExtendView.chatBlankButton.alpha = 0;
                    [weakSelf layoutIfNeeded];
                }];
            }
        }else {
            
            [weakSelf.giftListView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.bottom.mas_equalTo(252);
            }];
            [weakSelf.liveExtendView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(0);
                make.bottom.mas_equalTo(-52);
            }];
            [UIView animateWithDuration:.4 animations:^{
                weakSelf.playToolView.alpha = 1;
                weakSelf.liveExtendView.chatBlankButton.alpha = 0;
                weakSelf.liveExtendView.chatRoomView.alpha = 1;
                [weakSelf layoutIfNeeded];
            }];
        }
    }];
    
    
    self.liveExtendView.visitorsView.memberBlock = ^(NSString* net_ease_id){
        
        if([net_ease_id isEqualToString:WTConfig.net_accid]){
            [weakSelf showPopPersonViewDetail:WTConfig.user_id];
        }else {
            [weakSelf showPopPersonViewDetail:net_ease_id];
        }
        
    };
    
    self.liveExtendView.personInfoView.pressedBlock = ^(NSInteger index){
        if(index == 0){
            [weakSelf showPopPersonViewDetail:weakSelf.privateMessageView.anchor_info_model.anchor_user_id];
        }else {
            if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoView:focusUser_id:isFocus:)]){
                [weakSelf.delegate videoView:weakSelf focusUser_id:weakSelf.privateMessageView.anchor_info_model.anchor_user_id isFocus:!weakSelf.liveExtendView.personInfoView.isAttentioned];
            }
        }
    };
    
    self.popPersonInfoView.block = ^(WTPersonInfoType type){
        
        [weakSelf.personPopup dismiss:YES];
        if(type == WTPersonInfoPrivateMessageAction){ //私信
            
            weakSelf.currentIndex = 1;
            [weakSelf.privateMessageView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.bottom.mas_equalTo(0);
            }];
            [UIView animateWithDuration:.25 animations:^{
                weakSelf.liveExtendView.chatBlankButton.alpha = 1;
                [weakSelf layoutIfNeeded];
            }];
            [weakSelf.privateMessageView popKeyBoard];
            
        }else if(type == WTPersonInfoAttentionAction){ //关注
            if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoView:focusUser_id:isFocus:)]){
                [weakSelf.delegate videoView:weakSelf focusUser_id:weakSelf.privateMessageView.anchor_info_model.anchor_user_id isFocus:!weakSelf.popPersonInfoView.is_focused];
            }
        }else {
            
        }
    };
    
    [self.liveExtendView.coinView.detailButton addAction:^{
       
        if(weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoViewGiftDetail:)]){
            [weakSelf.delegate videoViewGiftDetail:weakSelf];
        }
    }];
    
    [self addkeyboardNotifications];
}

#pragma mark setter
- (void)setRoomId:(NSInteger)roomId{
    _roomId = roomId;
    
    //显示房间里面的观众
    self.liveExtendView.visitorsView.roomId = roomId;
}

#pragma mark private methods
- (NSInteger)countGiftNum:(WTChatRoomGiftModel*)chat_room_message_gift_model{
    return  chat_room_message_gift_model.gift_scale * chat_room_message_gift_model.gift_count * chat_room_message_gift_model.gift_price * 10 / 100;
}


- (BOOL)isPureNumandCharacters:(NSString *)string
{
    string = [string stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];
    if(string.length > 0)
    {
        return NO;
    }
    return YES;
}

- (void)showPopPersonViewDetail:(NSString*)net_ease_ID{
    
    KLCPopupLayout layout = KLCPopupLayoutMake(KLCPopupHorizontalLayoutCenter,KLCPopupVerticalLayoutCenter);
    KLCPopup* popup = nil;
    if(!self.personPopup){
        popup = [KLCPopup popupWithContentView:self.popPersonInfoView
                                      showType:KLCPopupShowTypeGrowIn
                                   dismissType:KLCPopupDismissTypeGrowOut
                                      maskType:KLCPopupMaskTypeDimmed
                      dismissOnBackgroundTouch:YES
                         dismissOnContentTouch:NO];
        self.personPopup = popup;
    }
    [self.personPopup showWithLayout:layout];
    self.popPersonInfoView.net_ease_ID = net_ease_ID;

    CGFloat infoViewHeight = 280;
    CGFloat toolHeight = 54;
    BOOL isHidden = NO;
    if(self.playToolView.isLivePage){
        infoViewHeight = 280 - 54;
        toolHeight = 0;
        isHidden = YES;
    }else {
        if([self isPureNumandCharacters:net_ease_ID]){ //15651017277 是user_id
            if([WTConfig.user_id isEqualToString:net_ease_ID]){
                infoViewHeight = 280 - 54;
                toolHeight = 0;
                isHidden = YES;
            }else {
                infoViewHeight = 280;
                toolHeight = 44;
                isHidden = NO;
                self.popPersonInfoView.is_focused = self.liveExtendView.personInfoView.isAttentioned;
            }
        }else {
            infoViewHeight = 280 - 54;
            toolHeight = 0;
            isHidden = YES;
        }
    }
    self.popPersonInfoView.height = infoViewHeight;
    [self.popPersonInfoView.toolView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(toolHeight);
    }];
    self.popPersonInfoView.toolView.hidden = isHidden;
}

- (void)addkeyboardNotifications{
    
    __weak __typeof(self) weakSelf = self;
    [self addListenerForNotificationName:UIKeyboardWillChangeFrameNotification handler:^(NSString *notificationName, NSDictionary *userInfo) {
        
        CGSize keyboardSize = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
        CGFloat height = keyboardSize.height;
        
        if(weakSelf.currentIndex == 0){
            [weakSelf.liveExtendView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(-height);
                make.bottom.mas_equalTo(-height);
            }];
            [weakSelf.liveExtendView.chatInputView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.height.mas_equalTo(40);
            }];
            [UIView animateWithDuration:.25 animations:^{
                weakSelf.liveExtendView.chatInputView.alpha = 1;
                weakSelf.liveExtendView.chatBlankButton.alpha = 1;
                [weakSelf layoutIfNeeded];
            }];
        }else if(weakSelf.currentIndex == 1){
            [weakSelf.privateMessageView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.bottom.mas_equalTo(-height);
            }];
            
            [UIView animateWithDuration:.25 animations:^{
                weakSelf.liveExtendView.chatBlankButton.alpha = 1;
                [weakSelf layoutIfNeeded];
            }];
        }else {
            
            
        }
    }];
    
    [self addListenerForNotificationName:UIKeyboardWillHideNotification handler:^(NSString *notificationName, NSDictionary *userInfo) {
        
        if(weakSelf.currentIndex == 0){
            
            [weakSelf.liveExtendView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.top.mas_equalTo(0);
                make.bottom.mas_equalTo(-52);
            }];
            [weakSelf.liveExtendView.chatInputView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.height.mas_equalTo(0);
            }];
            [UIView animateWithDuration:.25 animations:^{
                weakSelf.liveExtendView.chatInputView.alpha = 0;
                weakSelf.liveExtendView.chatBlankButton.alpha = 0;
                [weakSelf layoutIfNeeded];
            }];
        }else if(weakSelf.currentIndex == 1){
            [weakSelf.privateMessageView mas_updateConstraints:^(MASConstraintMaker *make) {
                make.bottom.mas_equalTo(0);
            }];
            [UIView animateWithDuration:.25 animations:^{
                [weakSelf layoutIfNeeded];
            }];
        }else {
            
            
        }
    }];
}

#pragma mark public
- (void)updateFocusStatus:(NSInteger)is_focus{
    
    self.popPersonInfoView.is_focused = is_focus;
    self.liveExtendView.personInfoView.isAttentioned = is_focus;
}

- (void)clearGiftAnimationCaches{
    [[WTGiftAnimationManager sharedManager] clear];
}

#pragma mark getter
- (WTPersonInfoView *)popPersonInfoView{
    if(!_popPersonInfoView){
        _popPersonInfoView = [[WTPersonInfoView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen screenWidth], 280)];
    }
    return _popPersonInfoView;
}

#pragma mark dealloc
- (void)dealloc{
    [[WTLiveSDK shareSDK].chatManager removeChatMessageLisenter];
}
@end
